/**
 * 用户认证服务器
 * 
 * 主要功能：
 * - 用户注册和登录
 *
 * @file server.js
 * @version 1.0.0
 * @author "nailuo"
 * @created 2025-8-30
 * @lastModified 2025-8-30
 */

const cors = require("cors");
const express = require("express");

const router = require("./routes/index.js")
const { logger, auth,session } = require("./middleware/index.js"); 

const app = express();



//跨域中间件
app.use(cors());
//解析请求体中间件
app.use(express.json());

//自定义中间件
app.use(logger);
app.use(session.setSession);
app.use(session.sessionMiddleware);
//app.use(auth);

// 路由中间件
app.use(router);

app.listen(process.env.port, process.env.host, () => {
    console.log(`💻服务器启动成功 http://${process.env.host}:${process.env.port}`);
    console.log(`🚀环境: ${process.env.env}`);
});